www.gusucode.com > XerCMS 携云PHP企业建站程序 v2015PHP源码程序 > XerCMS 携云PHP企业建站程序 v2015/XerCMS_v20150724/XerCMS_v20150724/XerCMS/Library/XerCMS_uri.php
<?php /** * @name XERCMS * @author Arno <XerCMS@163.com> [QQ:1328013] * @version 1.0.0 * @link http://www.XerCMS.com */ !defined('XERCMS') && exit('Access Denied'); class URI { static $URL; static $param; //static $rules = array(); static function obtain($key,$data) { switch($key) { case 'archive': return URLPATH.'archives/'.$data['column'].','.$data['id'].'.html'; break; } } static function parse() { self::$URL = isset($_SERVER['HTTP_X_REWRITE_URL']) && !empty($_SERVER['HTTP_X_REWRITE_URL']) ? $_SERVER['HTTP_X_REWRITE_URL'] : $_SERVER['REQUEST_URI']; if(strpos(self::$URL,'?') !== false){ return; } self::$param = array_filter(explode('/',self::$URL,10)); //print_r(self::$param); switch(self::$param[1]) { case 'column': self::column(); break; case 'archives': self::archives(); break; case 'member': self::member(); break; default: self::other(); break; } //print_r($_GET);exit; } static function other() { if(isset($_SERVER['QUERY_STRING']{5}) && count($_GET) == 1 && !isset($_SERVER['QUERY_STRING']{(strpos($_SERVER['QUERY_STRING'],'.html') + 5)})) { $url = explode('.',$_SERVER['QUERY_STRING']);unset($url[count($url) - 1]); $url = explode('/',implode('.',$url));$url = $url[count($url) - 1]; $url = explode('-',$url);$index = 0; foreach($url as $k=>$v) { if($index == 0) { $_GET[$v] = isset($url[$k + 1]) ? $url[$k + 1] : ''; $index = 1; } else $index = 0; } } } static function checkParams($number) { if(count(self::$param) != $number) { exit(); } } static function member() { self::checkParams(3);//print_r(self::$param);exit; //isset(self::$param[2]) if(self::$param[2] == 'publish'){ $_GET['m'] = 'archives'; $_GET['e'] = 'publish'; $temp = explode('.',self::$param[3]); $_GET['model'] = $temp[0]; unset($temp); } else { $_GET['m'] = 'member'; $_GET['e'] = self::$param[2]; } } static function archives() { $_GET['m'] = 'archives'; $_GET['e'] = 'detail'; if (isset(self::$param[2])) { $temp = explode('.',self::$param[2]); $temp = explode(',',$temp[0]); if (!isset($temp[1])) { return; } $_GET['column'] = (int)$temp[0]; $_GET['id'] = (int)$temp[1]; unset($temp); } } static function column() { $_GET['m'] = 'archives'; $_GET['e'] = 'column'; if (isset(self::$param[2])) { $temp = explode('.',self::$param[2]); $_GET['column'] = (int)$temp[0]; unset($temp); } } } ?>